*===============================================================================
* Replication Do-file
* Project: The Impact of the Tigray War on Child Education and Labor in Ethiopia
* Data Sources: Ethiopian Socioeconomic Survey (ESS) and ACLED Conflict Data
* Authors     : Dainn Wie, Demeke Yemareshet
* Affiliation : National Graduate Institute for Policy Studies, Tokyo, Japan
* Contact     : wie-dainn@grips.ac.jp, hailuyemar@gmail.com
* Description: Cleaning and analysis of ESS and ACLED data for main results
*===============================================================================

*===============================================================================
* Programs to be installed
* ssc install geodist
* ssc install reghdfe
* ssc install ftools
*===============================================================================

* Set working directory
* Change it to the Replication package

cd "C:\Users\wie-dainn\Dropbox\Work\Yema\Analysis.CH2"   //Dainn
*cd "C:\Users\hailu\Dropbox\Yema\Writing.CH2\Replication Package\" // Yema's path

* Load final dataset
clear all
set more off


/*
*********************************************************************************
* Table A4: Impact of Conflict on School Attendance Controlling for COVID-19 
*********************************************************************************

use "Data\ESS_2018_2021_hh_acled_final.DTA", clear

egen kid=group(region zone district kebele)

label var Exposure_20km_dummy "Serious incident within 20km"
label var Exposure_20km_continuous "Incident count within 20km"
label var Exposure_50km_dummy "Serious incident within 50km"
label var Exposure_50km_continuous "Incident count within 50km"


* Handle missing values and generate squared distance variable
egen mean_distance = mean(distance_hospital), by(region district)
replace distance_hospital = mean_distance if missing(distance_hospital)
replace distance_hospital = 0 if missing(distance_hospital)
gen distance_hospital_squ = distance_hospital^2

* Create dummy for proximity to hospital and interactions with conflict exposure
gen dist_hospital_close = distance_hospital <= 9
label variable dist_hospital_close "Having hospitals within 50km"

gen interaction_dist_20dum = Exposure_20km_dummy*dist_hospital_close
label variable interaction_dist_20dum "Conflict within 20km*Having hospitals within 9km"

gen interaction_dist_50dum = Exposure_50km_dummy*dist_hospital_close
label variable interaction_dist_50dum "Conflict within 50km*Having hospitals within 9km"


*(1)
reghdfe attending_school Exposure_20km_dummy distance_hospital distance_hospital_squ i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA4.doc, label dec(3) keep(Exposure_20km_dummy) replace title("Table A4: Impact of Conflict on School Attendance Controlling for Potential COVID-19 Effects") addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele) addnote(Note: Please see the note under the Table 1.)

*(2)
reghdfe attending_school Exposure_50km_dummy distance_hospital distance_hospital_squ i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA4.doc, label dec(3) keep(Exposure_50km_dummy) append addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele)

*(3)
reghdfe attending_school Exposure_20km_continuous distance_hospital distance_hospital_squ i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA4.doc, label dec(3) keep(Exposure_20km_continuous) append addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele)

*(4)
reghdfe attending_school Exposure_50km_continuous distance_hospital distance_hospital_squ i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA4.doc, label dec(3) keep(Exposure_50km_continuous) append addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele)




************************************************************
* TABLE A5 - The Impact of Conflict on Children's School Attendance by Parental SES
************************************************************

* Load the data
use "Data\ESS_2018_2021_hh_acled_final.DTA", clear
egen kid=group(region zone district kebele)

label var Exposure_20km_dummy "Conflict (20km)"
label var Exposure_20km_continuous "#Incidents (20km)"
label var Exposure_50km_dummy "Conflict (50km)"
label var Exposure_50km_continuous "#Incidents (50km)"

label var interaction_father_20dum "Conflict (20km)*High SES"
label var interaction_father_50dum "Conflict (50km)*High SES"
label var interaction_father_20cont "#Incidents (20km)*High SES"
label var interaction_father_50cont "#Incidents (50km)*High SES"

label var interaction_mother_20dum "Conflict (20km)*High SES"
label var interaction_mother_50dum "Conflict (50km)*High SES"
label var interaction_mother_20cont "#Incidents (20km)*High SES"
label var interaction_mother_50cont "#Incidents (50km)*High SES"


* Restrict sample to children with consistent father & mother education info
* Check and drop inconsistent father education info across rounds
by pid, sort: egen father_edu_max=max(father_high_SES)
by pid, sort: egen father_edu_min=min(father_high_SES)
gen dif=father_edu_max-father_edu_min
tab dif
drop if dif!=0

* Check and drop inconsistent mother education info across rounds 
by pid, sort: egen mother_edu_max=max(mother_high_SES)
by pid, sort: egen mother_edu_min=min(mother_high_SES)
gen diff=mother_edu_max-mother_edu_min
tab diff
drop if diff!=0

*(1) Father's Education -20km 
reghdfe attending_school Exposure_20km_dummy interaction_father_20dum i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA5.doc, label dec(3) keep(Exposure_20km_dummy interaction_father_20dum) replace ctitle(Father) title("Table A5:The Impact of Conflict on Children's School Attendance by Parental SES") addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele) addnote(Note: See the note under Table 1. Conflict is a binary indicator equal to 1 if at least one serious incident with more than five fatalities occurred within the stated distance and 0 otherwise. Incidents is the number of conflict incidents within the stated distance. High parental SES is defined as having at least one parent with at least secondary education.)

lincom Exposure_20km_dummy+interaction_father_20dum

*(2)  Father's Education -50km 
reghdfe attending_school Exposure_50km_dummy interaction_father_50dum i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA5.doc, label dec(3) keep(Exposure_50km_dummy interaction_father_50dum) append ctitle(Father)  addtext( Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele)

lincom Exposure_50km_dummy+interaction_father_50dum

*(3) Father's Education-Conflict Incident Counts 20km
reghdfe attending_school Exposure_20km_continuous interaction_father_20cont i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA5.doc, label dec(3) keep(Exposure_20km_continuous interaction_father_20cont) append ctitle(Father) addtext( Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele)

lincom Exposure_20km_continuous+interaction_father_20cont

*(4) Father's Education-Conflict Incident Counts 50km
reghdfe attending_school Exposure_50km_continuous interaction_father_50cont i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA5.doc, label dec(3) keep(Exposure_50km_continuous interaction_father_50cont) append ctitle(Father) addtext( Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele)

lincom Exposure_50km_continuous+interaction_father_50cont

*(5) Mother's Education -20km dummy)
reghdfe attending_school Exposure_20km_dummy interaction_mother_20dum i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA5.doc, label dec(3) keep(Exposure_20km_dummy interaction_mother_20dum) append ctitle(Mother)  addtext( Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele)

*(6) Mother's Education -50km dummy
reghdfe attending_school Exposure_50km_dummy interaction_mother_50dum i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA5.doc, label dec(3) keep(Exposure_50km_dummy interaction_mother_50dum) append ctitle(Mother)  addtext( Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele)

*(7) Mother's Education-Conflict Incident Counts 20km
reghdfe attending_school Exposure_20km_continuous interaction_mother_20cont i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA5.doc, label dec(3) keep(Exposure_20km_continuous interaction_mother_20cont) append ctitle(Mother)  addtext( Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele)

*(8) Mother's Education-Conflict Incident Counts 50km
reghdfe attending_school Exposure_50km_continuous interaction_mother_50cont i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA5.doc, label dec(3) keep(Exposure_50km_continuous interaction_mother_50cont) append ctitle(Mother) addtext( Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele)


************************************************************
* TABLE A6 - Impact of Conflict on Plans to Attend School Next Year
************************************************************

* Load data
use "Data\ESS_2018_2021_hh_acled_final.DTA", clear
egen kid=group(region zone district kebele)

label var Exposure_20km_dummy "Conflict (20km)"
label var Exposure_20km_continuous "#Incidents (20km)"
label var Exposure_50km_dummy "Conflict (50km)"
label var Exposure_50km_continuous "#Incidents (50km)"


* Label variable
label variable plan_school "Plans to attend school" 

* Drop missing values on key outcomes
drop if missing(attending_school)
drop if missing(plan_school)


* Generate dependent variable
gen NotAttending_noplans_attend = .
replace NotAttending_noplans_attend = 1 if attending_school == 0 & plan_school == 0
replace NotAttending_noplans_attend = 0 if NotAttending_noplans_attend == . 


*(1) 20km Dummy
reghdfe NotAttending_noplans_attend Exposure_20km_dummy i.age_years [pweight = hh_weight], absorb (pid  Year) vce (cluster kid)
outreg2 using Tables\tableA6.doc, label dec(3) keep(Exposure_20km_dummy) replace  title("Table A6: The Persistent Impact of Conflict on School Attendance") addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele) 

*(2) 50km Dummy
reghdfe NotAttending_noplans_attend Exposure_50km_dummy i.age_years [pweight = hh_weight], absorb (pid  Year) vce (cluster kid)
outreg2 using Tables\tableA6.doc, label dec(3) keep(Exposure_50km_dummy) append  addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele)


*(3) Incident counts 20km 
reghdfe NotAttending_noplans_attend Exposure_20km_continuous i.age_years [pweight = hh_weight], absorb (pid  Year) vce (cluster kid)
outreg2 using Tables\tableA6.doc, label dec(3) keep(Exposure_20km_continuous) append  addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele)

*(4) Incident counts 50km 
reghdfe NotAttending_noplans_attend Exposure_50km_continuous i.age_years [pweight = hh_weight], absorb (pid  Year) vce (cluster kid)
outreg2 using Tables\tableA6.doc, label dec(3) keep(Exposure_50km_continuous) append  addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele)


************************************************************
* TABLE A7 - Impact of Conflict on Plans to Attend School Next Year
************************************************************
use "Data\ESS_2018_2021_hh_acled_final.DTA", clear
egen kid=group(region zone district kebele)

label var Exposure_20km_dummy "Conflict (20km)"
label var Exposure_50km_dummy "Conflict (50km)"


* Construct mechanism variables
gen child_labour = .
replace child_labour = 1 if employed_cash_food == 1 | casual_labour_work == 1 | worked_free_others == 1 | free_labor_public == 1
replace child_labour = 0 if child_labour == . 

gen not_attending = .
replace not_attending = 1 if currently_attending_school == 2
replace not_attending = 0 if currently_attending_school == 1

gen child_notatt_labour = .
replace child_notatt_labour = 1 if child_labour == 1 & not_attending == 1
replace child_notatt_labour = 0 if child_notatt_labour == . 

gen child_notatt_unpaid = .
replace child_notatt_unpaid = 1 if worked_free_others == 1 & not_attending == 1
replace child_notatt_unpaid = 0 if child_notatt_unpaid == . 

gen child_notatt_free = .
replace child_notatt_free = 1 if free_labor_public == 1 & not_attending == 1
replace child_notatt_free = 0 if child_notatt_free == . 

drop if missing(attending_school) 

* Full sample
* Not attending school
*(1)
reghdfe not_attending Exposure_20km_dummy i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA7.doc, label dec(3) keep(Exposure_20km_dummy) replace ctitle(Not in School)  addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele) title("Table A7: Exploring Child Labor and School Attendance as a Joint Decision")
*(2)
reghdfe not_attending Exposure_50km_dummy i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA7.doc, label dec(3) keep(Exposure_50km_dummy) append addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele)

* Not in School & Child Labor
*(3)
reghdfe child_notatt_labour Exposure_20km_dummy i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA7.doc, label dec(3) keep(Exposure_20km_dummy) append ctitle(Not in School & Child Labor)  addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele)
*(4)
reghdfe child_notatt_labour Exposure_50km_dummy i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA7.doc, label dec(3) keep(Exposure_50km_dummy) append addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele)


* Not in School & Household Unpaid Labor
*(5)
reghdfe child_notatt_unpaid Exposure_20km_dummy i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA7.doc, label dec(3) keep(Exposure_20km_dummy) append ctitle(Not in School & Household Unpaid Labor)  addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele)
*(6)
reghdfe child_notatt_unpaid Exposure_50km_dummy i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA7.doc, label dec(3) keep(Exposure_50km_dummy) append addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele)

* Not in School & State-led Unpaid Labor
*(7)
reghdfe child_notatt_free Exposure_20km_dummy i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA7.doc, label dec(3) keep(Exposure_20km_dummy) append ctitle(Not in School & State-led Unpaid Labor)  addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele)
*(8)
reghdfe child_notatt_free Exposure_50km_dummy i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA7.doc, label dec(3) keep(Exposure_50km_dummy) append addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele)

************************************************************
* TABLE A8 - Placebo Test: The Impact of Conflict on Plans to Attend School
************************************************************
use "Data\ESS_2013_2015_hh_acled_final.DTA", clear
egen kid=group(region zone district kebele)

label var Exposure_20km_dummy "Serious incident within 20km"
label var Exposure_20km_continuous "Incident count within 20km"
label var Exposure_50km_dummy "Serious incident within 50km"
label var Exposure_50km_continuous "Incident count within 50km"

drop if missing(attending_school) 

label variable plan_school "Plan" 

* Full Sample
*(1)
reghdfe plan_school Exposure_20km_dummy i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA8.doc, label dec(3) keep(Exposure_20km_dummy) replace   addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele) title("A8: Placebo Test: The Impact of Conflict on Plans to Attend School Prior to the Conflict")
*(2)
reghdfe plan_school Exposure_50km_dummy i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA8.doc, label dec(3) keep(Exposure_50km_dummy) append   addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele)
*(3)
reghdfe plan_school Exposure_20km_continuous i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA8.doc, label dec(3) keep(Exposure_20km_continuous) append   addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele)
*(4)
reghdfe plan_school Exposure_50km_continuous i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA8.doc, label dec(3) keep(Exposure_50km_continuous) append   addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele)


* Boys
*(5)
reghdfe plan_school Exposure_20km_dummy i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA8.doc, label dec(3) keep(Exposure_20km_dummy) append   addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele)
*(6)
reghdfe plan_school Exposure_50km_dummy i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA8.doc, label dec(3) keep(Exposure_50km_dummy) append   addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele)
*(7)
reghdfe plan_school Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA8.doc, label dec(3) keep(Exposure_20km_continuous) append   addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele)
*(8)
reghdfe plan_school Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA8.doc, label dec(3) keep(Exposure_50km_continuous) append   addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Kebele)


***************************************************************************
*TABLE A9: Placebo Test: The Impact of Conflict on Child labour
***************************************************************************

use "Data\ESS_2013_2015_hh_acled_final.DTA", clear

egen kid=group(region zone district kebele)
label var Exposure_20km_dummy "Serious incident within 20km"
label var Exposure_20km_continuous "Incident count within 20km"
label var Exposure_50km_dummy "Serious incident within 50km"
label var Exposure_50km_continuous "Incident count within 50km"

* A: Employment for Cash/Food
* for Full sample
reghdfe employed_cash_food Exposure_20km_continuous i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA9A.doc, label dec(3) keep(Exposure_20km_continuous) replace ctitle((1))  title("A9: Placebo Test: The Impact of Conflict on Child labor Prior to Conflict")

reghdfe employed_cash_food Exposure_50km_continuous i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA9A.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((2))  

* Boys
reghdfe employed_cash_food Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA9A.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((3))  addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele)

reghdfe employed_cash_food Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA9A.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((4))  

* Girls
reghdfe employed_cash_food Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA9A.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((5))  

reghdfe employed_cash_food Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA9A.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((6))  

* B: : Temporary/Casual Work
* for Full sample
reghdfe casual_labour_work Exposure_20km_continuous i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA9B.doc, label dec(3) keep(Exposure_20km_continuous) replace ctitle((7))  
reghdfe casual_labour_work Exposure_50km_continuous i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA9B.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((8))  


* Boys 
reghdfe casual_labour_work Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA9B.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((9))  
reghdfe casual_labour_work Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA9B.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((10))  

* Girls
reghdfe casual_labour_work Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA9B.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((11))  
reghdfe casual_labour_work Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA9B.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((12))  

* C: Unpaid Labor
* for Full sample
reghdfe worked_free_others Exposure_20km_continuous i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA9C.doc, label dec(3) keep(Exposure_20km_continuous) replace ctitle((13))

reghdfe worked_free_others Exposure_50km_continuous i.age_years [pweight = hh_weight], absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA9C.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((14))  


* Boys
reghdfe worked_free_others Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA9C.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((15))  

reghdfe worked_free_others Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA9C.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((16))  


* Girls
reghdfe worked_free_others Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA9C.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((17))  

reghdfe worked_free_others Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA9C.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((18))  


***************************************************************************
*TABLE A10: The Impact of Conflict and Risk on School Attendance: Table2's Robustness
***************************************************************************

use "Data\ESS_2018_2021_hh_acled_final.DTA", clear
merge m:1 enumeration_areaid using "Data\erisk.dta"

egen kid=group(region zone district kebele)
label var Exposure_20km_dummy "Serious incident within 20km"
label var Exposure_20km_continuous "Incident count within 20km"
label var Exposure_50km_dummy "Serious incident within 50km"
label var Exposure_50km_continuous "Incident count within 50km"

gen interaction1=Exposure_20km_dummy*radw10
label var interaction1 "Conflict within 20*Risk Measure"
gen interaction2=Exposure_50km_dummy*radw10
label var interaction2 "Conflict within 50*Risk Measure"
gen interaction3=Exposure_20km_continuous*radw10
label var interaction3 "#Incidents(20k)*Risk Measure"
gen interaction4=Exposure_50km_continuous*radw10
label var interaction4 "#Incidents(50k)*Risk Measure"


*(1) Boys 20km Dummy
reghdfe attending_school Exposure_20km_dummy interaction1 i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid Year) vce (cluster kid)
lincom Exposure_20km_dummy+interaction1
outreg2 using Tables\tableA10.doc, label dec(3) keep(Exposure_20km_dummy interaction1) replace ctitle(Boys) title("Table A10: The Impact of Conflict and Risk of Conflict on School Attendance by Gender") addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele) addstat(Total impact of conflict, `r(estimate)', p-value, `r(p)')

*(2) Boys 50km Dummy
reghdfe attending_school Exposure_50km_dummy interaction2 i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid Year) vce (cluster kid)
lincom Exposure_50km_dummy+interaction2
outreg2 using Tables\tableA10.doc, label dec(3) keep(Exposure_50km_dummy interaction2) append ctitle(Boys) addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele) addstat(Total impact of conflict, `r(estimate)', p-value, `r(p)')

*(3) Boys 20km Incident counts
reghdfe attending_school Exposure_20km_continuous interaction3 i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid Year) vce (cluster kid)
lincom Exposure_20km_continuous+interaction3
outreg2 using Tables\tableA10.doc, label dec(3) keep(Exposure_20km_continuous interaction3) append ctitle(Boys) addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele) addstat(Total impact of conflict, `r(estimate)', p-value, `r(p)')

*(4) Boys 50km Incident counts
reghdfe attending_school Exposure_50km_continuous interaction4 i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid Year) vce (cluster kid)
lincom Exposure_50km_continuous+interaction4
outreg2 using Tables\tableA10.doc, label dec(3) keep(Exposure_50km_continuous interaction4) append ctitle(Boys) addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele) addstat(Total impact of conflict, `r(estimate)', p-value, `r(p)')

*(5) Girls 20km Dummy
reghdfe attending_school Exposure_20km_dummy interaction1 i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid Year) vce (cluster kid)
lincom Exposure_20km_dummy+interaction1
outreg2 using Tables\tableA10.doc, label dec(3) keep(Exposure_20km_dummy interaction1) append ctitle(Girls) addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele) addstat(Total impact of conflict, `r(estimate)', p-value, `r(p)')

*(6) Girls 50km Dummy
reghdfe attending_school Exposure_50km_dummy interaction2 i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid Year) vce (cluster kid)
lincom Exposure_50km_dummy+interaction2
outreg2 using Tables\tableA10.doc, label dec(3) keep(Exposure_50km_dummy interaction2) append ctitle(Girls) addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele) addstat(Total impact of conflict, `r(estimate)', p-value, `r(p)')

*(7) Girls 20km Incident counts
reghdfe attending_school Exposure_20km_continuous interaction3 i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid Year) vce (cluster kid)
lincom Exposure_20km_continuous+interaction3
outreg2 using Tables\tableA10.doc, label dec(3) keep(Exposure_20km_continuous interaction3) append ctitle(Girls) addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele) addstat(Total impact of conflict, `r(estimate)', p-value, `r(p)')

*(8) Girls 50km Incident counts
reghdfe attending_school Exposure_50km_continuous interaction4 i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid Year) vce (cluster kid)
lincom Exposure_50km_continuous+interaction4
outreg2 using Tables\tableA10.doc, label dec(3) keep(Exposure_50km_continuous interaction4) append ctitle(Girls) addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele) addstat(Total impact of conflict, `r(estimate)', p-value, `r(p)')


***************************************************************************
*TABLE A11: The Impact of Conflict and Risk on School Attendance: Table3's Robustness
***************************************************************************


use "Data\ESS_2018_2021_hh_acled_final.DTA", clear
drop _merge
merge m:1 enumeration_areaid using "Data\erisk.dta"

egen kid=group(region zone district kebele)

label var Exposure_20km_dummy "Conflict (20km)"
label var Exposure_20km_continuous "#Incidents (20km)"
label var Exposure_50km_dummy "Conflict (50km)"
label var Exposure_50km_continuous "#Incidents (50km)"

gen interaction1=Exposure_20km_dummy*radw10
label var interaction1 "Conflict within 20*Risk Measure"
gen interaction2=Exposure_50km_dummy*radw10
label var interaction2 "Conflict within 50*Risk Measure"
gen interaction3=Exposure_20km_continuous*radw10
label var interaction3 "#Incidents(20km)*Risk Measure"
gen interaction4=Exposure_50km_continuous*radw10
label var interaction4 "#Incidents(50km)*Risk Measure"

* Table A11-A: Employment for Cash/Food

*(1) Full sample-20KM
reghdfe employed_cash_food Exposure_20km_continuous interaction3 i.age_years [pweight = hh_weight], absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11A.doc, label dec(3) keep(Exposure_20km_continuous interaction3) replace ctitle(All) title("Table A11: The Impact of Conflict and Risk of Conflict on Child labor")
*(2) Full sample-50km
reghdfe employed_cash_food Exposure_50km_continuous interaction4 i.age_years [pweight = hh_weight], absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11A.doc, label dec(3) keep(Exposure_50km_continuous interaction4) append ctitle(All) 
*(3) Boys-20km
reghdfe employed_cash_food Exposure_20km_continuous interaction3 i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11A.doc, label dec(3) keep(Exposure_20km_continuous interaction3) append ctitle(Boys)  
*(4) Boys-50km
reghdfe employed_cash_food Exposure_50km_continuous interaction4 i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11A.doc, label dec(3) keep(Exposure_50km_continuous interaction4) append ctitle(Boys) 
*(5) Girls-20km
reghdfe employed_cash_food Exposure_20km_continuous interaction3 i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11A.doc, label dec(3) keep(Exposure_20km_continuous interaction3) append ctitle(Girls)  
*(6) Girls-50km
reghdfe employed_cash_food Exposure_50km_continuous interaction4 i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11A.doc, label dec(3) keep(Exposure_50km_continuous interaction4) append ctitle(Girls)  

* Table A11-B: Casual Labor

*(7) Full sample-20km
reghdfe casual_labour_work Exposure_20km_continuous interaction3 i.age_years [pweight = hh_weight], absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11B.doc, label dec(3) keep(Exposure_20km_continuous interaction3) replace ctitle((7))  
*(8) Full sample-50km
reghdfe casual_labour_work Exposure_50km_continuous interaction4 i.age_years [pweight = hh_weight], absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11B.doc, label dec(3) keep(Exposure_50km_continuous interaction4) append ctitle((8))  
*(9)  Boys-20km
reghdfe casual_labour_work Exposure_20km_continuous interaction3 i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11B.doc, label dec(3) keep(Exposure_20km_continuous interaction3) append ctitle((9))  
*(10) Boys-50km
reghdfe casual_labour_work Exposure_50km_continuous interaction4 i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11B.doc, label dec(3) keep(Exposure_50km_continuous interaction4) append ctitle((10))  
*(11) Girls-20km
reghdfe casual_labour_work Exposure_20km_continuous interaction3 i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11B.doc, label dec(3) keep(Exposure_20km_continuous interaction3) append ctitle((11))  
*(12) Girls-50km
reghdfe casual_labour_work Exposure_50km_continuous interaction4 i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11B.doc, label dec(3) keep(Exposure_50km_continuous interaction4) append ctitle((12))  

* Table A11-C: Unpaid Labor for Others

*(13)Full sample-20km
reghdfe worked_free_others Exposure_20km_continuous interaction3 i.age_years [pweight = hh_weight], absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11C.doc, label dec(3) keep(Exposure_20km_continuous interaction3) replace ctitle((13)) 
*(14)Full sample-50km
reghdfe worked_free_others Exposure_50km_continuous interaction4 i.age_years [pweight = hh_weight], absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11C.doc, label dec(3) keep(Exposure_50km_continuous interaction4) append ctitle((14))  
*(15)Boys-20km
reghdfe worked_free_others Exposure_20km_continuous interaction3 i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11C.doc, label dec(3) keep(Exposure_20km_continuous interaction3) append ctitle((15))  
*(16)Boys-50km
reghdfe worked_free_others Exposure_50km_continuous interaction4 i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11C.doc, label dec(3) keep(Exposure_50km_continuous interaction4) append ctitle((16))  
*(17)Girls-20km
reghdfe worked_free_others Exposure_20km_continuous interaction3 i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11C.doc, label dec(3) keep(Exposure_20km_continuous interaction3) append ctitle((17))  
*(18)Girls-50km
reghdfe worked_free_others Exposure_50km_continuous interaction4 i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11C.doc, label dec(3) keep(Exposure_50km_continuous interaction4) append ctitle((18))  

* Table A11-D: Free Public Work

*(19) Full sample-20km
reghdfe free_labor_public Exposure_20km_continuous interaction3 i.age_years [pweight = hh_weight], absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11D.doc, label dec(3) keep(Exposure_20km_continuous interaction3) replace ctitle((19))  
*(20) Full sample-50km
reghdfe free_labor_public Exposure_50km_continuous interaction4 i.age_years [pweight = hh_weight], absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11D.doc, label dec(3) keep(Exposure_50km_continuous interaction4) append ctitle((20))  
*(21) Boys-20km
reghdfe free_labor_public Exposure_20km_continuous interaction3 i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11D.doc, label dec(3) keep(Exposure_20km_continuous interaction3) append ctitle((21))  
*(22) Boys-50km
reghdfe free_labor_public Exposure_50km_continuous interaction4 i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11D.doc, label dec(3) keep(Exposure_50km_continuous interaction4) append ctitle((22))  
*(23) Girls-20km
reghdfe free_labor_public Exposure_20km_continuous interaction3 i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11D.doc, label dec(3) keep(Exposure_20km_continuous interaction3) append ctitle((23))  
*(24) Girls-50km
reghdfe free_labor_public Exposure_50km_continuous interaction4 i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA11D.doc, label dec(3) keep(Exposure_50km_continuous interaction4) append ctitle((24)) 


***************************************************************************
*TABLE A12: The Impact of Conflict and Risk on School Attendance: Table3's Robustness
***************************************************************************
use "Data\ESS_2018_2021_hh_acled_final.DTA", clear

* 1. Child observed in 2018 and 2021 (child-level indicators)
bysort pid: egen has2018 = max(Year == 2018)
bysort pid: egen has2021 = max(Year == 2021)

label var has2018 "Child observed in 2018"
label var has2021 "Child observed in 2021"

* 2. Household exists in 2021
bysort household_id: egen hh_2021 = max(Year == 2021)
label var hh_2021 "Household observed in 2021"

* 3. Attrition indicators (baseline = 2018)

* Child missing in 2021 but household still exists
gen child_missing_hh_exists = (Year == 2018 & has2021 == 0 & hh_2021 == 1)
label var child_missing_hh_exists "Child missing in 2021, household exists"

* Child and household both missing in 2021
gen child_hh_gone = (Year == 2018 & has2021 == 0 & hh_2021 == 0)
label var child_hh_gone "Child and household missing in 2021"
 
  
* Attrition - Conflict with Parental SES
 * Restrict sample to children with consistent father & mother education info
* Check and drop inconsistent father education info across rounds

by pid, sort: egen father_edu_max=max(father_high_SES)
by pid, sort: egen father_edu_min=min(father_high_SES)
gen dif=father_edu_max-father_edu_min
tab dif
drop if dif!=0

* Check and drop inconsistent mother education info across rounds 

by pid, sort: egen mother_edu_max=max(mother_high_SES)
by pid, sort: egen mother_edu_min=min(mother_high_SES)
gen diff=mother_edu_max-mother_edu_min
tab diff
drop if diff!=0

*** Create dummy variables for conflict exposure based on incidents and fatalities ***
*** Baseline exposure variables ***

gen Exposure_20km_dummy_2018 = exposed_dummy_20 
gen Exposure_50km_dummy_2018 = exposed_dummy_50 
gen Exposure_20km_continuous_2018 = Total_incidents_20 
gen Exposure_50km_continuous_2018 = Total_incidents_50 

label var Exposure_20km_dummy_2018 "Conflict (20km)"
label var Exposure_20km_continuous_2018 "#Incidents (20km)"
label var Exposure_50km_dummy_2018 "Conflict (50km)"
label var Exposure_50km_continuous_2018 "#Incidents (50km)"

*** Interaction terms with father's SES ***
gen Attrition_father_20dum = Exposure_20km_dummy_2018 * father_high_SES
gen Attrition_father_50dum = Exposure_50km_dummy_2018 * father_high_SES
gen Attrition_father_20cont = Exposure_20km_continuous_2018 * father_high_SES
gen Attrition_father_50cont = Exposure_50km_continuous_2018 * father_high_SES

label var Attrition_father_20dum "Conflict (20km)*High SES"
label var Attrition_father_50dum "Conflict (50km)*High SES"
label var Attrition_father_20cont "#Incidents (20km)*High SES"
label var Attrition_father_50cont "#Incidents (50km)*High SES"

*** Interaction terms with mother's SES ***

gen Attrition_mother_20dum = Exposure_20km_dummy_2018 * mother_high_SES
gen Attrition_mother_50dum = Exposure_50km_dummy_2018 * mother_high_SES
gen Attrition_mother_20cont = Exposure_20km_continuous_2018 * mother_high_SES
gen Attrition_mother_50cont = Exposure_50km_continuous_2018 * mother_high_SES

label var Attrition_mother_20dum "Conflict (20km)*High SES"
label var Attrition_mother_50dum "Conflict (50km)*High SES"
label var Attrition_mother_20cont "#Incidents (20km)*High SES"
label var Attrition_mother_50cont "#Incidents (50km)*High SES"

* Generate unique kebele ID
egen kid = group(region zone district kebele)

* FATHER SES INTERACTIONS
* Dummy 20km
		
reghdfe child_hh_gone Exposure_20km_dummy_2018 Attrition_father_20dum father_high_SES i.age_years ///
    [pweight = hh_weight] if Year==2018, absorb(district) vce(cluster kid)

outreg2 using Tables\tableA12.doc, label dec(3) ///
        keep(Exposure_20km_dummy_2018 Attrition_father_20dum father_high_SES) ///
        replace ctitle("Father") addtext(Distrit FE, Yes, Cluster SE, Kebele)

* Dummy 50km
reghdfe child_hh_gone Exposure_50km_dummy_2018 Attrition_father_50dum father_high_SES i.age_years ///
        [pweight = hh_weight] if Year==2018, absorb(district) vce(cluster kid)
		
outreg2 using Tables\tableA12.doc, label dec(3) ///
        keep(Exposure_50km_dummy_2018 Attrition_father_50dum father_high_SES) ///
        append ctitle("Father") addtext(District FE, Yes, Cluster SE, Kebele)

* Continuous 20km
reghdfe child_hh_gone Exposure_20km_continuous_2018 Attrition_father_20cont father_high_SES i.age_years ///
        [pweight = hh_weight] if Year==2018, absorb(district) vce(cluster kid)
outreg2 using Tables\tableA12.doc, label dec(3) ///
        keep(Exposure_20km_continuous_2018 Attrition_father_20cont father_high_SES) ///
        append ctitle("Father") addtext(District FE, Yes, Cluster SE, Kebele)

* Continuous 50km
reghdfe child_hh_gone Exposure_50km_continuous_2018 Attrition_father_50cont father_high_SES i.age_years ///
        [pweight = hh_weight] if Year==2018, absorb(district) vce(cluster kid)
outreg2 using Tables\tableA12.doc, label dec(3) ///
        keep(Exposure_50km_continuous_2018 Attrition_father_50cont father_high_SES) ///
        append ctitle("Father") addtext(District FE, Yes, Cluster SE, Kebele)

* MOTHER SES INTERACTIONS

* Dummy 20km
reghdfe child_hh_gone Exposure_20km_dummy_2018 Attrition_mother_20dum mother_high_SES i.age_years ///
        [pweight = hh_weight] if Year==2018, absorb(district) vce(cluster kid)
outreg2 using Tables\tableA12.doc, label dec(3) ///
        keep(Exposure_20km_dummy_2018 Attrition_mother_20dum mother_high_SES) ///
        append ctitle("Mother") addtext(District FE, Yes, Cluster SE, Kebele)

* Dummy 50km
reghdfe child_hh_gone Exposure_50km_dummy_2018 Attrition_mother_50dum mother_high_SES i.age_years ///
        [pweight = hh_weight] if Year==2018, absorb(district) vce(cluster kid)
outreg2 using Tables\tableA12.doc, label dec(3) ///
        keep(Exposure_50km_dummy_2018 Attrition_mother_50dum mother_high_SES) ///
        append ctitle("Mother") addtext(District FE, Yes, Cluster SE, Kebele)

* Continuous 20km
reghdfe child_hh_gone Exposure_20km_continuous_2018 Attrition_mother_20cont mother_high_SES i.age_years ///
        [pweight = hh_weight] if Year==2018, absorb(district) vce(cluster kid)
outreg2 using Tables\tableA12.doc, label dec(3) ///
        keep(Exposure_20km_continuous_2018 Attrition_mother_20cont mother_high_SES) ///
        append ctitle("Mother") addtext(District FE, Yes, Cluster SE, Kebele)

* Continuous 50km
reghdfe child_hh_gone Exposure_50km_continuous_2018 Attrition_mother_50cont mother_high_SES i.age_years ///
        [pweight = hh_weight] if Year==2018, absorb(district) vce(cluster kid)
outreg2 using Tables\tableA12.doc, label dec(3) ///
        keep(Exposure_50km_continuous_2018 Attrition_mother_50cont mother_high_SES) ///
        append ctitle("Mother") addtext(District FE, Yes, Cluster SE, Kebele)


**********************************************************************
* TABLE A13 - Table2's Robustness Test using Alternative Fixed Effects
* Heterogeneous Effects by Child Sex (Male vs. Female)
**********************************************************************

use "Data\ESS_2018_2021_hh_acled_final.DTA", clear

egen kid=group(region zone district kebele)

label var Exposure_20km_dummy "Serious incident within 20km"
label var Exposure_20km_continuous "Incident count within 20km"
label var Exposure_50km_dummy "Serious incident within 50km"
label var Exposure_50km_continuous "Incident count within 50km"

gen age2018_temp=age_years if Year==2018
by pid, sort: egen age2018=max(age2018_temp)
drop if age2018>=17

* MALE CHILDREN ONLY (sex_new == 1)
* (1) 20km Dummy
reghdfe attending_school Exposure_20km_dummy i.age_years i.age2018 [pweight = hh_weight] if sex_new == 1, absorb (household_id Year) vce (cluster kid) 

outreg2 using Tables\tableA13.doc, label dec(3) keep(Exposure_20km_dummy) replace ctitle(Boys) addtext( Household FE, Yes,  Year FE, Yes, Cluster, Kebele) title("Robustness Test of Table 2 using Alternative Fixed Effects") 

* (2) 50km Dummy
reghdfe attending_school Exposure_50km_dummy i.age_years i.age2018 [pweight = hh_weight] if sex_new == 1, absorb (household_id Year) vce (cluster kid)
outreg2 using Tables\tableA13.doc, label dec(3) keep(Exposure_50km_dummy) append ctitle(Boys) addtext( Household FE, Yes,  Year FE, Yes, Cluster, Kebele)

* (3) 20km Continuous
reghdfe attending_school Exposure_20km_continuous i.age_years i.age2018 [pweight = hh_weight] if sex_new == 1, absorb (household_id Year) vce (cluster kid)
outreg2 using Tables\tableA13.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle(Boys) addtext( Household FE, Yes,  Year FE, Yes, Cluster, Kebele)

* (4) 50km Continuous
reghdfe attending_school Exposure_50km_continuous i.age_years i.age2018 [pweight = hh_weight] if sex_new == 1, absorb (household_id Year) vce (cluster kid)
outreg2 using Tables\tableA13.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle(Boys) addtext(Household FE, Yes,  Year FE, Yes, Cluster, Kebele)

* FEMALE CHILDREN ONLY (sex_new == 0)
* (5) 20km Dummy
reghdfe attending_school Exposure_20km_dummy i.age_years i.age2018 [pweight = hh_weight] if sex_new == 0, absorb (household_id Year) vce (cluster kid)
outreg2 using Tables\tableA13.doc, label dec(3) keep(Exposure_20km_dummy) append ctitle(Girls) addtext( Household FE, Yes,  Year FE, Yes, Cluster, Kebele)

* (6) 50km Dummy
reghdfe attending_school Exposure_50km_dummy i.age_years i.age2018 [pweight = hh_weight] if sex_new == 0, absorb (household_id Year) vce (cluster kid)
outreg2 using Tables\tableA13.doc, label dec(3) keep(Exposure_50km_dummy) append ctitle(Girls) addtext( Household FE, Yes,  Year FE, Yes, Cluster, Kebele)

* (7) 20km Continuous
reghdfe attending_school Exposure_20km_continuous i.age_years i.age2018 [pweight = hh_weight] if sex_new == 0, absorb (household_id Year) vce (cluster kid)
outreg2 using Tables\tableA13.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle(Girls) addtext( Household FE, Yes,  Year FE, Yes, Cluster, Kebele)

* (8) 50km Continuous
reghdfe attending_school Exposure_50km_continuous i.age_years i.age2018 [pweight = hh_weight] if sex_new == 0, absorb (household_id Year) vce (cluster kid)
outreg2 using Tables\tableA13.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle(Girls) addtext(Household FE, Yes,  Year FE, Yes, Cluster, Kebele)


**********************************************************************
* TABLE A14 - Table3's Robustness Test using Alternative Fixed Effects
* Conflict and Child Labor (Four Types)
**********************************************************************

use "Data\ESS_2018_2021_hh_acled_final.DTA", clear

egen kid=group(region zone district kebele)

label var Exposure_20km_dummy "Serious incident within 20km"
label var Exposure_20km_continuous "Incident count within 20km"
label var Exposure_50km_dummy "Serious incident within 50km"
label var Exposure_50km_continuous "Incident count within 50km"

gen age2018_temp=age_years if Year==2018
by pid, sort: egen age2018=max(age2018_temp)
drop if age2018>=17

* Table A14-A: Employment for Cash/Food

* Full sample
reghdfe employed_cash_food Exposure_20km_continuous i.age_years i.age2018 [pweight = hh_weight], absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14A.doc, label dec(3) keep(Exposure_20km_continuous) replace ctitle((1)) title("Robustness Test of Table 3 using Alternative Fixed Effects") 

reghdfe employed_cash_food Exposure_50km_continuous i.age_years i.age2018 [pweight = hh_weight], absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14A.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((2))  

* Sex = Male
reghdfe employed_cash_food Exposure_20km_continuous i.age_years i.age2018 [pweight = hh_weight] if sex_new == 1, absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14A.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((3)) 
reghdfe employed_cash_food Exposure_50km_continuous i.age_years i.age2018 [pweight = hh_weight] if sex_new == 1, absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14A.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((4))  

* Sex = Female
reghdfe employed_cash_food Exposure_20km_continuous i.age_years i.age2018 [pweight = hh_weight] if sex_new == 0, absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14A.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((5))  

reghdfe employed_cash_food Exposure_50km_continuous i.age_years i.age2018 [pweight = hh_weight] if sex_new == 0, absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14A.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((6))  

* Table A14-B: Casual Labor
* Full sample
reghdfe casual_labour_work Exposure_20km_continuous i.age_years i.age2018 [pweight = hh_weight], absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14B.doc, label dec(3) keep(Exposure_20km_continuous) replace ctitle((7))  

reghdfe casual_labour_work Exposure_50km_continuous i.age_years i.age2018 [pweight = hh_weight], absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14B.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((8))  

* Sex = Male
reghdfe casual_labour_work Exposure_20km_continuous i.age_years i.age2018 [pweight = hh_weight] if sex_new == 1, absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14B.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((9))  

reghdfe casual_labour_work Exposure_50km_continuous i.age_years i.age2018 [pweight = hh_weight] if sex_new == 1, absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14B.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((10))  

* Sex = Female
reghdfe casual_labour_work Exposure_20km_continuous i.age_years i.age2018 [pweight = hh_weight] if sex_new == 0, absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14B.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((11))  

reghdfe casual_labour_work Exposure_50km_continuous i.age_years i.age2018 [pweight = hh_weight] if sex_new == 0, absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14B.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((12))  

* Table A14-C: Unpaid for Others

* Full sample
reghdfe worked_free_others Exposure_20km_continuous i.age_years i.age2018 [pweight = hh_weight], absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14C.doc, label dec(3) keep(Exposure_20km_continuous) replace ctitle((13))  

reghdfe worked_free_others Exposure_50km_continuous i.age_years i.age2018 [pweight = hh_weight], absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14C.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((14))  

* Sex = Male
reghdfe worked_free_others Exposure_20km_continuous i.age_years i.age2018 [pweight = hh_weight] if sex_new == 1, absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14C.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((15))  

reghdfe worked_free_others Exposure_50km_continuous i.age_years i.age2018 [pweight = hh_weight] if sex_new == 1, absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14C.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((16))  

* Sex = Female
reghdfe worked_free_others Exposure_20km_continuous i.age_years i.age2018 [pweight = hh_weight] if sex_new == 0, absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14C.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((17))  

reghdfe worked_free_others Exposure_50km_continuous i.age_years i.age2018 [pweight = hh_weight] if sex_new == 0, absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14C.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((18))  

* * Table A14-D: Free Public Work
* Full sample
reghdfe free_labor_public Exposure_20km_continuous i.age_years i.age2018 [pweight = hh_weight], absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14D.doc, label dec(3) keep(Exposure_20km_continuous) replace ctitle((19))  

reghdfe free_labor_public Exposure_50km_continuous i.age_years i.age2018 [pweight = hh_weight], absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14D.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((20))  

* Sex = Male
reghdfe free_labor_public Exposure_20km_continuous i.age_years i.age2018 [pweight = hh_weight] if sex_new == 1, absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14D.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((21))  

reghdfe free_labor_public Exposure_50km_continuous i.age_years i.age2018 [pweight = hh_weight] if sex_new == 1, absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14D.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((22))  

* Sex = Female
reghdfe free_labor_public Exposure_20km_continuous i.age_years i.age2018 [pweight = hh_weight] if sex_new == 0, absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14D.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((23))  

reghdfe free_labor_public Exposure_50km_continuous i.age_years i.age2018 [pweight = hh_weight] if sex_new == 0, absorb(household_id Year) vce(cluster kid)
outreg2 using Tables\tableA14D.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((24))  




**********************************************************************
* TABLE A15 - Table4's Robustness Test using Alternative Fixed Effects
* Joint Decision of Conflict and Child Labor 
**********************************************************************

use "Data\ESS_2018_2021_hh_acled_final.DTA", clear
egen kid=group(region zone district kebele)

label var Exposure_20km_dummy "Conflict (20km)"
label var Exposure_50km_dummy "Conflict (50km)"

gen age2018_temp=age_years if Year==2018
by pid, sort: egen age2018=max(age2018_temp)
drop if age2018>=17


* Construct Variables
gen child_labour = .
replace child_labour = 1 if employed_cash_food == 1 | casual_labour_work == 1 | worked_free_others == 1 | free_labor_public == 1
replace child_labour = 0 if child_labour == . 

gen not_attending = .
replace not_attending = 1 if currently_attending_school == 2
replace not_attending = 0 if currently_attending_school == 1

gen child_notatt_labour = .
replace child_notatt_labour = 1 if child_labour == 1 & not_attending == 1
replace child_notatt_labour = 0 if child_notatt_labour == . 

gen child_notatt_unpaid = .
replace child_notatt_unpaid = 1 if worked_free_others == 1 & not_attending == 1
replace child_notatt_unpaid = 0 if child_notatt_unpaid == . 

gen child_notatt_free = .
replace child_notatt_free = 1 if free_labor_public == 1 & not_attending == 1
replace child_notatt_free = 0 if child_notatt_free == . 

drop if missing(attending_school) 

*(1)Boys Unpaid Household Labor-20km
reghdfe child_notatt_unpaid Exposure_20km_dummy i.age_years i.age2018 [pweight = hh_weight] if sex_new == 1, absorb (household_id Year) vce (cluster kid)
outreg2 using Tables\tableA15.doc, label dec(3) keep(Exposure_20km_dummy) replace addtext(Household FE, Yes, Year FE, Yes, Cluster SE, Kebele) title("Table A15: Robustness Test of Table 4 Using Alternative Fixed Effects")

*(2)Boys Unpaid Household Labor-50km
reghdfe child_notatt_unpaid Exposure_50km_dummy i.age_years i.age2018 [pweight = hh_weight] if sex_new == 1, absorb (household_id Year) vce (cluster kid)
outreg2 using Tables\tableA15.doc, label dec(3) keep(Exposure_50km_dummy) append addtext(Household FE, Yes, Year FE, Yes, Cluster SE, Kebele)

*(3)Boys State-led Unpaid Labor-20km
reghdfe child_notatt_free Exposure_20km_dummy i.age_years i.age2018 [pweight = hh_weight] if sex_new == 1, absorb (household_id Year) vce (cluster kid)
outreg2 using Tables\tableA15.doc, label dec(3) keep(Exposure_20km_dummy) append addtext(Household FE, Yes, Year FE, Yes, Cluster SE, Kebele)

*(4)Boys State-led Unpaid Labor-50km
reghdfe child_notatt_free Exposure_50km_dummy i.age_years i.age2018 [pweight = hh_weight] if sex_new == 1, absorb (household_id Year) vce (cluster kid)
outreg2 using Tables\tableA15.doc, label dec(3) keep(Exposure_50km_dummy) append addtext(Household FE, Yes, Year FE, Yes, Cluster SE, Kebele)


*(5)Girls Unpaid Household Labor-20km
reghdfe child_notatt_unpaid Exposure_20km_dummy i.age_years i.age2018 [pweight = hh_weight] if sex_new == 0, absorb (household_id Year) vce (cluster kid)
outreg2 using Tables\tableA15.doc, label dec(3) keep(Exposure_20km_dummy) append addtext(Household FE, Yes, Year FE, Yes, Cluster SE, Kebele)

*(6)Girls Unpaid Household Labor-50km
reghdfe child_notatt_unpaid Exposure_50km_dummy i.age_years i.age2018 [pweight = hh_weight] if sex_new == 0, absorb (household_id Year) vce (cluster kid)
outreg2 using Tables\tableA15.doc, label dec(3) keep(Exposure_50km_dummy) append addtext(Household FE, Yes, Year FE, Yes, Cluster SE, Kebele)

*(7)Girls State-led Unpaid Labor-20km
reghdfe child_notatt_free Exposure_20km_dummy i.age_years i.age2018 [pweight = hh_weight] if sex_new == 0, absorb (household_id Year) vce (cluster kid)
outreg2 using Tables\tableA15.doc, label dec(3) keep(Exposure_20km_dummy) append addtext(Household FE, Yes, Year FE, Yes, Cluster SE, Kebele)

*(8)Girls State-led Unpaid Labor-50km
reghdfe child_notatt_free Exposure_50km_dummy i.age_years i.age2018 [pweight = hh_weight] if sex_new == 0, absorb (household_id Year) vce (cluster kid)
outreg2 using Tables\tableA15.doc, label dec(3) keep(Exposure_50km_dummy) append addtext(Household FE, Yes, Year FE, Yes, Cluster SE, Kebele)


**********************************************************************
* TABLE A16 - Table2's Robustness Test using Two-Way Fixed Effects
**********************************************************************

use "Data\ESS_2018_2021_hh_acled_final.DTA", clear
egen kid=group(region zone district kebele)
egen distyear=group(district Year)


label var Exposure_20km_dummy "Serious incident within 20km"
label var Exposure_20km_continuous "Incident count within 20km"
label var Exposure_50km_dummy "Serious incident within 50km"
label var Exposure_50km_continuous "Incident count within 50km"

*(1) Boys 20km Dummy
reghdfe attending_school Exposure_20km_dummy i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid distyear) vce (cluster kid)
outreg2 using Tables\tableA16.doc, label dec(3) keep(Exposure_20km_dummy) replace ctitle(Boys) title("Table A16: Table2's Robustness Test using Two-Way Fixed Effects") addtext(Child FE, Yes,  District-Year FE, Yes, Cluster SE, Kebele) addnote(Note: See note under Table 1.)
*(2) Boys 50km Dummy
reghdfe attending_school Exposure_50km_dummy i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid distyear) vce (cluster kid)
outreg2 using Tables\tableA16.doc, label dec(3) keep(Exposure_50km_dummy) append ctitle(Boys) addtext(Child FE, Yes,  District-Year FE, Yes, Cluster SE, Kebele)
*(3) Boys 20km Incident counts
reghdfe attending_school Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid distyear) vce (cluster kid)
outreg2 using Tables\tableA16.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle(Boys) addtext(Child FE, Yes,  District-Year FE, Yes, Cluster SE, Kebele)
*(4) Boys 50km Incident counts
reghdfe attending_school Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid distyear) vce (cluster kid)
outreg2 using Tables\tableA16.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle(Boys) addtext(Child FE, Yes,  District-Year FE, Yes, Cluster SE, Kebele)
*(5) Girls 20km Dummy
reghdfe attending_school Exposure_20km_dummy i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid distyear) vce (cluster kid)
outreg2 using Tables\tableA16.doc, label dec(3) keep(Exposure_20km_dummy) append ctitle(Girls) addtext(Child FE, Yes,  District-Year FE, Yes, Cluster SE, Kebele)
*(6) Girls 50km Dummy
reghdfe attending_school Exposure_50km_dummy i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid distyear) vce (cluster kid)
outreg2 using Tables\tableA16.doc, label dec(3) keep(Exposure_50km_dummy) append ctitle(Girls) addtext(Child FE, Yes,  District-Year FE, Yes, Cluster SE, Kebele)
*(7) Girls 20km Incident counts
reghdfe attending_school Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid distyear) vce (cluster kid)
outreg2 using Tables\tableA16.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle(Girls)  addtext(Child FE, Yes,  District-Year FE, Yes, Cluster SE, Kebele)
*(8) Girls 50km Incident counts
reghdfe attending_school Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid distyear) vce (cluster kid)
outreg2 using Tables\tableA16.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle(Girls)  addtext(Child FE, Yes,  District-Year FE, Yes, Cluster SE, Kebele)



**********************************************************************
* TABLE A17 - Table3's Robustness Test using Two-Way Fixed Effects
**********************************************************************

use "Data\ESS_2018_2021_hh_acled_final.DTA", clear
egen kid=group(region zone district kebele)
egen distyear=group(district Year)

label var Exposure_20km_dummy "Conflict (20km)"
label var Exposure_20km_continuous "#Incidents (20km)"
label var Exposure_50km_dummy "Conflict (50km)"
label var Exposure_50km_continuous "#Incidents (50km)"


* Table A: Employment for Cash/Food

*(1) Full sample-20KM
reghdfe employed_cash_food Exposure_20km_continuous i.age_years [pweight = hh_weight], absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17A.doc, label dec(3) keep(Exposure_20km_continuous) replace ctitle(All) title("Table A17: Table3's Robustness Test using Two-Way Fixed Effects") 
*(2) Full sample-50km
reghdfe employed_cash_food Exposure_50km_continuous i.age_years [pweight = hh_weight], absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17A.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle(All) 
*(3) Boys-20km
reghdfe employed_cash_food Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17A.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle(Boys)  
*(4) Boys-50km
reghdfe employed_cash_food Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17A.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle(Boys) 
*(5) Girls-20km
reghdfe employed_cash_food Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17A.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle(Girls)  
*(6) Girls-50km
reghdfe employed_cash_food Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17A.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle(Girls)  

* Table B: Casual Labor

*(7) Full sample-20km
reghdfe casual_labour_work Exposure_20km_continuous i.age_years [pweight = hh_weight], absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17B.doc, label dec(3) keep(Exposure_20km_continuous) replace ctitle((7))  
*(8) Full sample-50km
reghdfe casual_labour_work Exposure_50km_continuous i.age_years [pweight = hh_weight], absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17B.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((8))  
*(9)  Boys-20km
reghdfe casual_labour_work Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17B.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((9))  
*(10) Boys-50km
reghdfe casual_labour_work Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17B.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((10))  
*(11) Girls-20km
reghdfe casual_labour_work Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17B.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((11))  
*(12) Girls-50km
reghdfe casual_labour_work Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17B.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((12))  

* Table C: Unpaid Labor for Others

*(13)Full sample-20km
reghdfe worked_free_others Exposure_20km_continuous i.age_years [pweight = hh_weight], absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17C.doc, label dec(3) keep(Exposure_20km_continuous) replace ctitle((13)) 
*(14)Full sample-50km
reghdfe worked_free_others Exposure_50km_continuous i.age_years [pweight = hh_weight], absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17C.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((14))  
*(15)Boys-20km
reghdfe worked_free_others Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17C.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((15))  
*(16)Boys-50km
reghdfe worked_free_others Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17C.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((16))  
*(17)Girls-20km
reghdfe worked_free_others Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17C.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((17))  
sleep 100
*(18)Girls-50km
reghdfe worked_free_others Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17C.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((18))  

* Table D: Free Public Work

*(19) Full sample-20km
reghdfe free_labor_public Exposure_20km_continuous i.age_years [pweight = hh_weight], absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17D.doc, label dec(3) keep(Exposure_20km_continuous) replace ctitle((19))  
*(20) Full sample-50km
reghdfe free_labor_public Exposure_50km_continuous i.age_years [pweight = hh_weight], absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17D.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((20))  
*(21) Boys-20km
reghdfe free_labor_public Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17D.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((21))  
*(22) Boys-50km
reghdfe free_labor_public Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17D.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((22))  
*(23) Girls-20km
reghdfe free_labor_public Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17D.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((23))  
*(24) Girls-50km
reghdfe free_labor_public Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid distyear) vce(cluster kid)
outreg2 using Tables\tableA17D.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((24)) 
*/

**********************************************************************
* TABLE A18 - Table4's Robustness Test using Two-Way Fixed Effects
**********************************************************************

use "Data\ESS_2018_2021_hh_acled_final.DTA", clear

egen kid=group(region zone district kebele)
egen distyear=group(district Year)

label var Exposure_20km_dummy "Conflict (20km)"
label var Exposure_50km_dummy "Conflict (50km)"

* Construct Variables
gen child_labour = .
replace child_labour = 1 if employed_cash_food == 1 | casual_labour_work == 1 | worked_free_others == 1 | free_labor_public == 1
replace child_labour = 0 if child_labour == . 

gen not_attending = .
replace not_attending = 1 if currently_attending_school == 2
replace not_attending = 0 if currently_attending_school == 1

gen child_notatt_labour = .
replace child_notatt_labour = 1 if child_labour == 1 & not_attending == 1
replace child_notatt_labour = 0 if child_notatt_labour == . 

gen child_notatt_unpaid = .
replace child_notatt_unpaid = 1 if worked_free_others == 1 & not_attending == 1
replace child_notatt_unpaid = 0 if child_notatt_unpaid == . 

gen child_notatt_free = .
replace child_notatt_free = 1 if free_labor_public == 1 & not_attending == 1
replace child_notatt_free = 0 if child_notatt_free == . 

drop if missing(attending_school) 
*(1)Boys Unpaid Household Labor-20km
reghdfe child_notatt_unpaid Exposure_20km_dummy i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid distyear) vce (cluster kid)
outreg2 using Tables\tableA18.doc, label dec(3) keep(Exposure_20km_dummy) replace addtext(Child FE, Yes, District-Year FE, Yes, Cluster SE, Kebele) title("Table A18: Table4's Robustness Test using Two-Way Fixed Effects")

*(2)Boys Unpaid Household Labor-50km
reghdfe child_notatt_unpaid Exposure_50km_dummy i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid distyear) vce (cluster kid)
outreg2 using Tables\tableA18.doc, label dec(3) keep(Exposure_50km_dummy) append addtext(Child FE, Yes, District-Year FE, Yes, Cluster SE, Kebele)

*(3)Boys State-led Unpaid Labor-20km
reghdfe child_notatt_free Exposure_20km_dummy i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid distyear) vce (cluster kid)
outreg2 using Tables\tableA18.doc, label dec(3) keep(Exposure_20km_dummy) append addtext(Child FE, Yes, District-Year FE, Yes, Cluster SE, Kebele)

*(4)Boys State-led Unpaid Labor-50km
reghdfe child_notatt_free Exposure_50km_dummy i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid distyear) vce (cluster kid)
outreg2 using Tables\tableA18.doc, label dec(3) keep(Exposure_50km_dummy) append addtext(Child FE, Yes, District-Year FE, Yes, Cluster SE, Kebele)


*(5)Girls Unpaid Household Labor-20km
reghdfe child_notatt_unpaid Exposure_20km_dummy i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid distyear) vce (cluster kid)
outreg2 using Tables\tableA18.doc, label dec(3) keep(Exposure_20km_dummy) append addtext(Child FE, Yes, District-Year FE, Yes, Cluster SE, Kebele)

*(6)Girls Unpaid Household Labor-50km
reghdfe child_notatt_unpaid Exposure_50km_dummy i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid distyear) vce (cluster kid)
outreg2 using Tables\tableA18.doc, label dec(3) keep(Exposure_50km_dummy) append addtext(Child FE, Yes, District-Year FE, Yes, Cluster SE, Kebele)

*(7)Girls State-led Unpaid Labor-20km
reghdfe child_notatt_free Exposure_20km_dummy i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid distyear) vce (cluster kid)
outreg2 using Tables\tableA18.doc, label dec(3) keep(Exposure_20km_dummy) append addtext(Child FE, Yes, District-Year FE, Yes, Cluster SE, Kebele)

*(8)Girls State-led Unpaid Labor-50km
reghdfe child_notatt_free Exposure_50km_dummy i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid distyear) vce (cluster kid)
outreg2 using Tables\tableA18.doc, label dec(3) keep(Exposure_50km_dummy) append addtext(Child FE, Yes, District-Year FE, Yes, Cluster SE, Kebele)

/

********************************************************************************
*Table A19: Table 2's Robustness Test using UCDP Data
********************************************************************************

use "Data\ESS_2018_2021_hh_ucdp_final.DTA", clear

egen kid=group(region zone district kebele)
label var Exposure_20km_dummy "Serious incident within 20km"
label var Exposure_20km_continuous "Incident count within 20km"
label var Exposure_50km_dummy "Serious incident within 50km"
label var Exposure_50km_continuous "Incident count within 50km"
* MALE CHILDREN ONLY (sex_new == 1)

* 20km Dummy
reghdfe attending_school Exposure_20km_dummy i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid  Year) vce (cluster kid)
outreg2 using Tables\tableA19.doc, label dec(3) keep(Exposure_20km_dummy) replace  addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Yes) title("Table A19: Robustness Test of Table 2 Using Measure of Conflict from UCDP Data")

* 50km Dummy
reghdfe attending_school Exposure_50km_dummy i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid  Year) vce (cluster kid)
outreg2 using Tables\tableA19.doc, label dec(3) keep(Exposure_50km_dummy) append   addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Yes)

* 20km Continuous
reghdfe attending_school Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid  Year) vce (cluster kid)
outreg2 using Tables\tableA19.doc, label dec(3) keep(Exposure_20km_continuous) append   addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Yes)

* 50km Continuous
reghdfe attending_school Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid  Year) vce (cluster kid)
outreg2 using Tables\tableA19.doc, label dec(3) keep(Exposure_50km_continuous) append   addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Yes)


* FEMALE CHILDREN ONLY (sex_new == 0)
* 20km Dummy
reghdfe attending_school Exposure_20km_dummy i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid  Year) vce (cluster kid)
outreg2 using Tables\tableA19.doc, label dec(3) keep(Exposure_20km_dummy) append   addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Yes)

* 50km Dummy
reghdfe attending_school Exposure_50km_dummy i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid  Year) vce (cluster kid)
outreg2 using Tables\tableA19.doc, label dec(3) keep(Exposure_50km_dummy) append   addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Yes)

* 20km Continuous
reghdfe attending_school Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid  Year) vce (cluster kid)
outreg2 using Tables\tableA19.doc, label dec(3) keep(Exposure_20km_continuous) append   addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Yes)

* 50km Continuous
reghdfe attending_school Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid  Year) vce (cluster kid)
outreg2 using Tables\tableA19.doc, label dec(3) keep(Exposure_50km_continuous) append   addtext(Child FE, Yes,  Year FE, Yes, Cluster SE, Yes)


********************************************************************************
*Table A20: Table 3's Robustness Test using UCDP Data
********************************************************************************

use "Data\ESS_2018_2021_hh_ucdp_final.DTA", clear

egen kid=group(region zone district kebele)

label var Exposure_20km_dummy "Conflict (20km)"
label var Exposure_20km_continuous "#Incidents (20km)"
label var Exposure_50km_dummy "Conflict (50km)"
label var Exposure_50km_continuous "#Incidents (50km)"

* Table A20A: Employment for Cash/Food

*(1) Full sample-20KM
reghdfe employed_cash_food Exposure_20km_continuous i.age_years [pweight = hh_weight], absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20A.doc, label dec(3) keep(Exposure_20km_continuous) replace ctitle(All) title("Table A20: Robustness Test of Table 3 Using Measure of Conflict from UCDP Data") 
*(2) Full sample-50km
reghdfe employed_cash_food Exposure_50km_continuous i.age_years [pweight = hh_weight], absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20A.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle(All) 
*(3) Boys-20km
reghdfe employed_cash_food Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20A.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle(Boys)  
*(4) Boys-50km
reghdfe employed_cash_food Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20A.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle(Boys) 
*(5) Girls-20km
reghdfe employed_cash_food Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20A.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle(Girls)  
*(6) Girls-50km
reghdfe employed_cash_food Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20A.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle(Girls)  

* Table A20B: Casual Labor

*(7) Full sample-20km
reghdfe casual_labour_work Exposure_20km_continuous i.age_years [pweight = hh_weight], absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20B.doc, label dec(3) keep(Exposure_20km_continuous) replace ctitle((7))  
*(8) Full sample-50km
reghdfe casual_labour_work Exposure_50km_continuous i.age_years [pweight = hh_weight], absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20B.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((8))  
sleep 100

*(9)  Boys-20km
reghdfe casual_labour_work Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20B.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((9))  
*(10) Boys-50km
reghdfe casual_labour_work Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20B.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((10))  
*(11) Girls-20km
reghdfe casual_labour_work Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20B.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((11))  
*(12) Girls-50km
reghdfe casual_labour_work Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20B.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((12))  

* Table A20C: Unpaid Labor for Others

*(13)Full sample-20km
reghdfe worked_free_others Exposure_20km_continuous i.age_years [pweight = hh_weight], absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20C.doc, label dec(3) keep(Exposure_20km_continuous) replace ctitle((13)) 
*(14)Full sample-50km
reghdfe worked_free_others Exposure_50km_continuous i.age_years [pweight = hh_weight], absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20C.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((14))  
*(15)Boys-20km
reghdfe worked_free_others Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20C.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((15))  
*(16)Boys-50km
reghdfe worked_free_others Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20C.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((16))  
*(17)Girls-20km
reghdfe worked_free_others Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20C.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((17))  
*(18)Girls-50km
reghdfe worked_free_others Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20C.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((18))  

* Table A20D: Free Public Work

*(19) Full sample-20km
reghdfe free_labor_public Exposure_20km_continuous i.age_years [pweight = hh_weight], absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20D.doc, label dec(3) keep(Exposure_20km_continuous) replace ctitle((19))  
*(20) Full sample-50km
reghdfe free_labor_public Exposure_50km_continuous i.age_years [pweight = hh_weight], absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20D.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((20))  
*(21) Boys-20km
reghdfe free_labor_public Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20D.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((21))  
*(22) Boys-50km
reghdfe free_labor_public Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 1, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20D.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((22))  
*(23) Girls-20km
reghdfe free_labor_public Exposure_20km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20D.doc, label dec(3) keep(Exposure_20km_continuous) append ctitle((23))  
*(24) Girls-50km
reghdfe free_labor_public Exposure_50km_continuous i.age_years [pweight = hh_weight] if sex_new == 0, absorb(pid Year) vce(cluster kid)
outreg2 using Tables\tableA20D.doc, label dec(3) keep(Exposure_50km_continuous) append ctitle((24)) 


*/

********************************************************************************
*Table A21: Table 4's Robustness Test using UCDP Data
********************************************************************************

use "Data\ESS_2018_2021_hh_ucdp_final.DTA", clear

egen kid=group(region zone district kebele)

label var Exposure_20km_dummy "Conflict (20km)"
label var Exposure_50km_dummy "Conflict (50km)"

* Construct Variables
gen child_labour = .
replace child_labour = 1 if employed_cash_food == 1 | casual_labour_work == 1 | worked_free_others == 1 | free_labor_public == 1
replace child_labour = 0 if child_labour == . 

gen not_attending = .
replace not_attending = 1 if currently_attending_school == 2
replace not_attending = 0 if currently_attending_school == 1

gen child_notatt_labour = .
replace child_notatt_labour = 1 if child_labour == 1 & not_attending == 1
replace child_notatt_labour = 0 if child_notatt_labour == . 

gen child_notatt_unpaid = .
replace child_notatt_unpaid = 1 if worked_free_others == 1 & not_attending == 1
replace child_notatt_unpaid = 0 if child_notatt_unpaid == . 

gen child_notatt_free = .
replace child_notatt_free = 1 if free_labor_public == 1 & not_attending == 1
replace child_notatt_free = 0 if child_notatt_free == . 

drop if missing(attending_school) 


*(1)Boys Unpaid Household Labor-20km
reghdfe child_notatt_unpaid Exposure_20km_dummy i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA21.doc, label dec(3) keep(Exposure_20km_dummy) replace addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele) title("Table A21: Robustness Test of Table 3 Using Measure of Conflict from UCDP Data") 

*(2)Boys Unpaid Household Labor-50km
reghdfe child_notatt_unpaid Exposure_50km_dummy i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA21.doc, label dec(3) keep(Exposure_50km_dummy) append addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele)

*(3)Boys State-led Unpaid Labor-20km
reghdfe child_notatt_free Exposure_20km_dummy i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA21.doc, label dec(3) keep(Exposure_20km_dummy) append addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele)

*(4)Boys State-led Unpaid Labor-50km
reghdfe child_notatt_free Exposure_50km_dummy i.age_years [pweight = hh_weight] if sex_new == 1, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA21.doc, label dec(3) keep(Exposure_50km_dummy) append addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele)


*(5)Girls Unpaid Household Labor-20km
reghdfe child_notatt_unpaid Exposure_20km_dummy i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA21.doc, label dec(3) keep(Exposure_20km_dummy) append addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele)

*(6)Girls Unpaid Household Labor-50km
reghdfe child_notatt_unpaid Exposure_50km_dummy i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA21.doc, label dec(3) keep(Exposure_50km_dummy) append addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele)

*(7)Girls State-led Unpaid Labor-20km
reghdfe child_notatt_free Exposure_20km_dummy i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA21.doc, label dec(3) keep(Exposure_20km_dummy) append addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele)

*(8)Girls State-led Unpaid Labor-50km
reghdfe child_notatt_free Exposure_50km_dummy i.age_years [pweight = hh_weight] if sex_new == 0, absorb (pid Year) vce (cluster kid)
outreg2 using Tables\tableA21.doc, label dec(3) keep(Exposure_50km_dummy) append addtext(Child FE, Yes, Year FE, Yes, Cluster SE, Kebele)


